package com.zsr.chapter03.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author zsr
 * @Description HttpServlet打印乘法口诀
 * @Version 1.0
 */
public class ServletDemo2 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        String method = request.getMethod();
        PrintWriter out = response.getWriter();
        out.println(method + "提交方式");
        out.print("<br/>");

        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= i; j++) {
                response.getWriter().print(j + "*" + i + "=" + j * i + " ");
            }
            out.print("<br/>");
        }
    }
}
